package com.plian.system.dao.sys.announcements;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import com.plian.system.model.page.Page;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class AnnouncementsDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;

    /**
     * 保存
     */
    public void save(PageData pd) throws Exception {
        dao.save("AnnouncementsMapper.save",pd);
    }

    /**
     * 修改
     * @param pd
     */
    public void edit(PageData pd) throws Exception {
        dao.update("AnnouncementsMapper.edit",pd);
    }
    public void del_ids(List<String> ids) throws Exception {
        dao.delete("AnnouncementsMapper.del_ids",ids);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    public PageData findId(String id) throws Exception {
        return (PageData) dao.findForObject("AnnouncementsMapper.findbyId",id);
    }

    /**
     * 列表查询
     * @param page
     * @return
     * @throws Exception
     */
    public List<PageData> listPage(Page page) throws Exception {
         return (List<PageData>) dao.findForList("AnnouncementsMapper.listPage",page);
    }

    /**
     * 批量调整发布
     */
    public void ChagPublishAll(PageData pd) throws Exception {
        dao.update("AnnouncementsMapper.ChagPublishAll",pd);
    }
    /**
     * 批量调整置顶
     */
    public void ChagtopAll(PageData pd) throws Exception {
        dao.update("AnnouncementsMapper.ChagtopAll",pd);
    }
}
